//package cn.lanqiao.springboot.config;
//
//import cn.lanqiao.springboot.entity.Role;
//import cn.lanqiao.springboot.mapper.MenuMapper;
//import cn.lanqiao.springboot.mapper.RoleMapper;
//import cn.lanqiao.springboot.redis.MenuRedisRepository;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
//@Slf4j
//@Component
//public class CachePreLoad implements ApplicationRunner {
//
//    @Autowired
//    RoleMapper roleMapper;
//
//    @Autowired
//    MenuMapper menuMapper;
//
//    @Autowired
//    MenuRedisRepository menuRedisRepository;
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
//        log.debug("开始缓存预热...");
//        //获得roleId的list
//        List<Role> roleList = roleMapper.getList(null);
//        //循环roleId的list，获得对应的menuList，存入redis
//        for (Role role : roleList){
//            menuRedisRepository.save(role.getRoleId(), menuMapper.getList(role.getRoleId()));
//        }
//        log.debug("缓存预热完成");
//    }
//}
